package com.android.nearshop.util;

import java.util.HashMap;
import java.util.Map;

/*********************************************************
 * @author : zhaohua
 * @version : 2012-8-8
 * @see : 数据传递缓冲
 * @Copyright : copyrights reserved by personal 2007-2011
 **********************************************************/
public class DataCache {
	private static Map<String, Object> mCache = new HashMap<String, Object>();
	
	/**
	 * 缓存数据
	 * @param key
	 * @param value
	 */
	public static void setValue(String key, Object value){
		mCache.put(key, value);
	}
	
	/**
	 * 由key获得缓存数据
	 * @param key
	 * @return
	 */
	public static Object getValue(String key){
		return mCache.get(key);
	}
	
	/**
	 * 由key获得int数据
	 * @param key
	 * @param defaultValue  默认数据
	 * @return
	 */
	public static int getInt(String key, int defaultValue){
		try{
			return (Integer) mCache.get(key);
		}catch (Exception e) {
			return defaultValue;
		}
	}
}
